import request from '../../utils/request';
const team = {
  state: {

  },

  getters: {

  },

  mutations: {

  },

  actions: {
    /**
     * 获取专家团队列表
     * @payload{
     *  name  string 
     * }
     * */ 
    GET_TEAM_LIST({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/expert/list.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },
    
    /***
     * 专家团队-新建/更新
     * @params payload{
     *  id string 专家id,为null新建，否则修改
     *  name string 姓名
     *  licenseNo string 律师证编号
     *  education string 	教育背景
     *  advantage string 优势
     *  pic       string 专家图片
     *  major     string 专业资质
     *  desc      string 简介
     * }
     * */ 
    HANDLE_EXPERT({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/expert/save.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 删除专家
     * @param id string 
     * */ 
    DELETE_EXPERT({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/expert/delete.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 获取专家详情
     * @param id string 
     * */ 
    GET_EXPERT_DETAIL({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/expert/detail.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    }

  }
}

export default team